package cn.techwis.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

@NoArgsConstructor
@Data
@AllArgsConstructor
@Builder
public class PayRefundsVO {


    /**
     * 微信支付订单号
     */
    private String transaction_id;

    /**
     * 商户订单号
     */
    private String out_trade_no;

    /**
     * 商户退款单号
     */
    @NotEmpty(message = "商户退款单号不能为空", groups = {PayRefunds.class})
    private String out_refund_no;
    /**
     * 退款原因
     */
    private String reason;
    /**
     * 退款结果回调url
     */
    private String notify_url;

    /**
     * 退款资金来源
     */
    private String funds_account;

    /**
     * 金额信息
     */
    @NotNull(message = "金额信息不能为空", groups = {PayRefunds.class})
    @Valid
    private AmountVO amount;

    /**
     * +退款商品
     */
    private List<GoodsDetailVO> goods_detail;

    @NoArgsConstructor
    @Data
    @AllArgsConstructor
    @Builder
    public static class AmountVO {

        /**
         * 退款金额
         */
        @NotNull(message = "退款金额不能为空", groups = {PayRefunds.class})
        private int refund;
        /**
         * 原订单金额
         */
        @NotNull(message = "原订单金额不能为空", groups = {PayRefunds.class})
        private int total;
        /**
         * 退款币种
         */
        @NotNull(message = "退款币种不能为空", groups = {PayRefunds.class})
        private String currency = "CNY";
    }


    @NoArgsConstructor
    @Data
    @Builder
    @AllArgsConstructor
    public static class GoodsDetailVO {

        /**
         * 商户侧商品编码
         */
        private String merchant_goods_id;

        /**
         * 微信侧商品编码
         */
        private String wechatpay_goods_id;

        /**
         * 商品名称
         */
        private String goods_name;

        /**
         * ]
         * 商品数量
         */

        /**
         * 商品单价
         */
        private int unit_price;

        /**
         * 退款金额
         */
        private int refund_amount;


        /**
         * 商品退货数量
         */
        private int refund_quantity;
    }


    public @interface PayRefunds {
    }
}
